
{extend name='public/base' /}

{block name="content"}

<div class="layui-col-md12">

    <div class="layui-card">
        <div class="layui-card-header" style="line-height: 55px;">
            <div class="layui-btn-container do_btn">
                <!--按钮区-->
                <button class="layui-btn layui-btn-sm layui-btn-primary" data-type="reload"><i class="fa fa-refresh"></i> 刷新</button>
            </div>
        </div>
        <div class="layui-card-body">
            <!--表格区-->
            <div class="yys-fluid yys-wrapper">
                <div class="layui-row lay-col-space20">
                    <div class="layui-cos-xs12 layui-col-sm12 layui-col-md12 layui-col-lg12">
                        <section class="yys-body">
                            <div class="yys-body-content clearfix changepwd">
                                <div class="layui-col-lg12 layui-col-md10 layui-col-sm12 layui-col-xs12" style="width:100%">
                                    <div class="user-tables">
                                        <table id="tableFilter" lay-filter="tableFilter"> </table>
                                    </div>
                                </div>
                            </div>
                        </section>
                    </div>
                </div>
            </div>

        </div>
    </div>

</div>


{/block}

{block name="js"} <!--js处理区-->

<script type="text/html" id="content">
{{qqWechatEmotionParser(d.content)}}
</script>

<script type="text/html" id="action">
    <a class="layui-btn layui-btn-xs" lay-event="reply"><i class="layui-icon layui-icon-reply-fill"></i></a>
    {:widget('common/forms/Delbtn',array('删除消息',2))}
</script>


<script type="text/html" id="create_time">
    {{layui.util.toDateString(d.create_time*1000, 'yyyy-MM-dd HH:mm:ss')}}
</script>

<script type="text/html" id="update_time">
    {{layui.util.toDateString(d.create_time*1000, 'yyyy-MM-dd HH:mm:ss')}}
</script>

<script src="__WECHAT__/emoji/qq-wechat-emotion-parser.min.js?v={:time()}"></script>

<script>

    layui.use(['element', 'table', 'form', 'jquery', 'lucky'], function () {
        var element = layui.element;
        var form = layui.form;
        var table = layui.table;
        var $ = layui.jquery;
        var lucky=layui.lucky;

        table.render({
            elem: '#tableFilter',
            url:"{:url('message')}",
            even: true, //开启隔行背景
            id:'table_id',
            page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip','last'] //自定义分页布局
                ,groups: 5 //只显示 1 个连续页码
                ,first: false //不显示首页
                ,last: false //不显示尾页
                ,limit:30
                ,limits:[10,20,30,50]
            },
            //height: 'full-100',
            text: {
                none: '暂无相关数据'
            },
            method: 'post',
            cols: [[
                {field: 'id', title: 'ID', width: 80,  sort: true},
                {field: 'nickname', title: '昵称', width: 120,},
                {field: 'openid', title: 'openid', width: 120,},
                {field: 'content', title: '内容', width: 120,templet:"#content"},
                {field: 'type', title: '类型', width: 120,},
                {field: 'event', title: '事件', width: 120,},
                {field: 'create_time', title: '添加时间', width: 180,templet:'#create_time'},
                {field: 'update_time', title: '更新时间', width: 180,templet:'#update_time'},
                {title:'操作',width:150, toolbar: '#action',align:"center"},
            ]],
            done: function (res) {
                layer.closeAll('loading');
            }
        });


        table.on('tool(tableFilter)', function (obj) {
            var data = obj.data;
            var _id=parseInt(data.id);
            var layEvent = obj.event;
            if(layEvent==="reply"){
                var u='{:url("messageReply")}'+'?id='+_id;
               lucky.CreateForm("回复消息","75%","88",u,"table_id");
               return false;

            }else if(layEvent==="del"){
                lucky.Delete_data(_id,"{:url('messageDel')}","table_id");

            }
        });

    })
</script>
{/block}

